//
//  TFMoreView.swift
//  TalkfunSDKDemo
//
//  Created by 邓盛明 on 2022/2/16.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TFMoreView: UIView {
    var lineView = UIView.init()

    /**公告*/
   @objc public var announcementBtn = TFMoreViewButton.init()

    /**网络选择*/
    @objc public var networkSelectBtn = TFMoreViewButton()
    @objc public let courseDownloadBtn = TFMoreViewButton()
    @objc public var courseDownShow:Bool = false
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)

        self.lineView.backgroundColor = UIColor(red: 242/255.0, green: 242/255.0, blue: 242/255.0, alpha: 1.0)
        addSubview(self.lineView)
     

        self.announcementBtn.img.image = UIImage.init(named: "HTLive.bundle/asklist_more")
        self.announcementBtn.lab.text = "公告";
        addSubview(self.announcementBtn)
        

        self.networkSelectBtn.img.image = UIImage.init(named: "HTLive.bundle/net_more")
        self.networkSelectBtn.lab.text = "网络选择";
        self.networkSelectBtn.isHidden = true;
        addSubview(self.networkSelectBtn)
        
        self.courseDownloadBtn.img.image = UIImage.init(named: "HTLive.bundle/kejianDown")
        self.courseDownloadBtn.lab.text = "课件下载";
        addSubview(self.courseDownloadBtn)

    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        self.lineView.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: 1)
        self.announcementBtn.frame = CGRect(x: 0, y: 1, width: self.frame.size.width/4.0, height: self.frame.size.height-1)
      
        self.networkSelectBtn.frame = CGRect(x: self.announcementBtn.frame.maxX, y: 1, width: self.frame.size.width/4.0, height: self.frame.size.height-1)
        
        
        if self.networkSelectBtn.isHidden {
            self.courseDownloadBtn.frame = self.networkSelectBtn.frame
        }else
        {
            self.courseDownloadBtn.frame = CGRect(x: self.networkSelectBtn.frame.maxX, y: 1, width: self.frame.size.width / 4.0, height: self.frame.size.height - 1)
        }
        
     
      
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
   
    
    @objc public func courseDown(_ isShow:Bool)
    {
        self.courseDownloadBtn.isHidden = !isShow;

    }

}
